package com.sayimo.maker.mall.goods.dao.impl;


import java.math.BigDecimal;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Repository;

import com.sayimo.framework.database.mybatis.AbstractMybatisBaseDao;
import com.sayimo.framework.exception.DaoException;
import com.sayimo.maker.mall.goods.dao.GoodsListInterfaceDao;
import com.sayimo.maker.mall.goods.vo.GoodsList;



/**
 * @Project: schoolmallapi
 * @ClassName: GoodsListInterfaceDao
 * @Description: 商品列表dao
 * @Author: 曹频辉
 * @Date: 日期：2016年1月4日 时间：上午10:09:03
 * @Version 1.0.0
 */
@Repository(value="goodsListInterfaceImplDao")
public class GoodsListInterfaceImplDao extends AbstractMybatisBaseDao<GoodsList> implements GoodsListInterfaceDao{
	
	/**
	* @Title: getGoodsByGoodsId 
	* @Description: 通过商品Id 查询商品
	* @param goodsId
	* @throws DaoException
	* @return Map
	 */
	@SuppressWarnings("rawtypes")
	public Map getGoodsByGoodsId(Integer goodsId) throws DaoException {	
		return (Map)this.mybatisInterfaceBaseDao.getObject("com.sayimo.maker.mall.goods.dao.GoodsListInterfaceDao.getGoodsByGoodsId", goodsId);
	}
	/**
	* @Title: getPhotosBygoodsId 
	* @Description: 商品图片
	* @param goodsId
	* @throws DaoException
	* @return List
	 */
	@SuppressWarnings("rawtypes")
	@Override
	public List getPhotosBygoodsId(Integer goodsId) throws DaoException {
		return this.mybatisInterfaceBaseDao.queryObject("com.sayimo.maker.mall.goods.dao.GoodsListInterfaceDao.getPhotosByGoodsId", goodsId);
	}
	/**
	* @Title: getAllNormsByGoodsId 
	* @Description: 商品规格
	* @param goodsId
	* @param normsValueId
	* @throws DaoException
	* @return Map
	 */
	@SuppressWarnings("rawtypes")
	@Override
	public Map getAllNormsByGoodsId(Integer goodsId,Integer normsValueId) throws DaoException {
		Map map=new HashMap();
		map.put("goodsId", goodsId);
		map.put("normsValueId", normsValueId);
		return (Map)this.mybatisInterfaceBaseDao.getObject("com.sayimo.maker.mall.goods.dao.GoodsListInterfaceDao.getAllNormsByGoodsId", map);
	}
	
	@Override
	public GoodsList queryGoodsListById(Integer id) throws DaoException {
		return mybatisInterfaceBaseDao.get("com.sayimo.maker.mall.goods.dao.GoodsListInterfaceDao.queryGoodsListById", id);
	}
	
	/**
	 * 
	 * @MethodName searchGoodsByName
	 * @Description 商品首页搜索
	 * 
	 * @author chenpy
	 * @date 2016年1月6日 下午3:47:58
	 * @param 
	 * @return List<GoodsList>
	 * @VERSION 1.0.0
	 */
	@SuppressWarnings("rawtypes")
	public List searchGoodsByName(String goodsName) throws DaoException {
		return mybatisInterfaceBaseDao.queryObject("com.sayimo.maker.mall.goods.dao.GoodsListInterfaceDao.searchGoodsByName", goodsName);
	}
	
	public Integer getGoodsCount() throws DaoException {
		return mybatisInterfaceBaseDao.queryCount("com.sayimo.maker.mall.goods.dao.GoodsListInterfaceDao.getGoodsCount");
	}
	
	public List<GoodsList> selectGoodsInfoByOrdersIds(List<Integer> ordersIds) throws DaoException {
		return this.mybatisInterfaceBaseDao.query("com.sayimo.maker.mall.goods.dao.GoodsListInterfaceDao.selectGoodsInfoByOrdersIds", ordersIds);
	}
	
	/**
	 * 
	 * @MethodName batchUpdateGoodsList
	 * @Description 批量修改商品信息
	 * 
	 * @author chenpy
	 * @date 2016年1月8日 下午5:20:16
	 * @param 
	 * @return int
	 * @VERSION 1.0.0
	 */
	public int batchUpdateGoodsList(List<GoodsList> goodsLists) throws DaoException{
		return this.mybatisInterfaceBaseDao.update("com.sayimo.maker.mall.goods.dao.GoodsListInterfaceDao.batchUpdateGoodsList", goodsLists);
	}
	@Override
	public List<Object> queryGoodsListProviderByIds(List<Integer> ids) throws DaoException {
		return mybatisInterfaceBaseDao.queryObject("com.sayimo.maker.mall.goods.dao.GoodsListInterfaceDao.queryGoodsListProviderByIds", ids);
	}
	
	public List<Object> queryGoodsBrokerageByIds(List<Integer> ids) throws DaoException {
		return mybatisInterfaceBaseDao.queryObject("com.sayimo.maker.mall.goods.dao.GoodsListInterfaceDao.queryGoodsBrokerageByIds", ids);
	}
	
	
	public Map queryGoodsBrokerageById(Integer id) throws DaoException {
		
		return mybatisInterfaceBaseDao.queryMap("com.sayimo.maker.mall.goods.dao.GoodsListInterfaceDao.queryGoodsBrokerageById", "id", id);
	}
	
	/**
	 * 
	* @Title: getLogisticsCostByAreaCode 
	* @Description: 根据地址编码查询 运费
	* @param areaCode
	* @param goodsId
	* @return
	* @throws DaoException
	* @return BigDecimal
	* @throws
	 */
	@Override
	public BigDecimal getLogisticsCostByAreaCode(String areaCode,Integer goodsId,Integer logisticsCostId)
			throws DaoException {
		Map map=new HashMap();
		map.put("areaCode", areaCode);
		map.put("goodsId", goodsId);
		map.put("logisticsCostId", logisticsCostId);
		return (BigDecimal)this.mybatisInterfaceBaseDao.getObject("com.sayimo.maker.mall.goods.dao.GoodsListInterfaceDao.getLogisticsCostByAreaCode", map);
	}
	
	/**
	 * 
	* @Title: getGoodsIdsByActivityId 
	* @Description: 获取活动关联商品
	* @param activityId
	* @return
	* @throws DaoException
	* @return String
	* @throws
	 */
	@Override
	public String getActivityIdentifier(Integer activityId)
			throws DaoException {
		return (String)this.mybatisInterfaceBaseDao.getObject("com.sayimo.maker.mall.goods.dao.GoodsListInterfaceDao.getActivityIdentifier", activityId);
	}
	
	/**
	 * 
	* @Title: getGoodsInfoByGoodsId 
	* @Description: 根据商品ID 获取商品信息
	* @param goodsId
	* @return
	* @throws DaoException
	* @return Map<String,Object>
	* @throws
	 */
	@Override
	public Map<String, Object> getGoodsInfoByGoodsId(Integer goodsId,String goodsName)
			throws DaoException {
		Map map=new HashMap();
		map.put("goodsId", goodsId);
		map.put("goodsName", goodsName);
		return (Map<String, Object>)this.mybatisInterfaceBaseDao.getObject("com.sayimo.maker.mall.goods.dao.GoodsListInterfaceDao.getGoodsInfoByGoodsId", map);
	}
	
	
	/**
	 * 
	* @Title: getShoppingCartGoodsProviders 
	* @Description: 获取特奢汇用户的id
	* @param customerId
	* @return
	* @throws DaoException
	* @return List
	* @throws
	 */
	@Override
	public GoodsList getProviderIdByCode(String providerCode) throws DaoException {
		return this.mybatisInterfaceBaseDao.get("com.sayimo.maker.mall.goods.dao.GoodsListInterfaceDao.getProviderIdByCode",providerCode);

	}
	
	/**
	 * @Title: getShoppingCartGoodsProviders 
	* @Description: 根据商品id更新商品状态
	* @param customerId
	* @return
	* @throws DaoException
	* @return List
	* @throws
	 */
	@Override
	public Integer updateStatus(Map<String, Object> paramMap) throws DaoException {
		return this.mybatisInterfaceBaseDao.update("com.sayimo.maker.mall.goods.dao.GoodsListInterfaceDao.updateStatus",paramMap);
	}
	
	/**
	 * 
	* @Title: queryProviderId 
	* @Author: 田超
	* @Date:日期：2016年7月12日  时间：下午3:09:32
	* @Description: 根据商品id查询商品的供应商
	* @param goodsId
	* @return
	* @throws DaoException
	* @return GoodsList
	* @Version 1.0.0
	 */
	@Override
	public GoodsList queryProviderId(Integer goodsId) throws DaoException {
		return this.mybatisInterfaceBaseDao.get("com.sayimo.maker.mall.goods.dao.GoodsListInterfaceDao.queryProviderId",goodsId);
	}
	
	/**
	 * 
	* @Title: querySkucodeById 
	* @Author: 田超
	* @Date:日期：2016年7月12日  时间：下午2:42:20
	* @Description: 根据商品ID和规格id获取skucode
	* @param paramMap
	* @return
	* @throws DaoException
	* @return Map<String,Object>
	* @Version 1.0.0
	 */
	@SuppressWarnings("unchecked")
	@Override
	public Map<String, Object> querySkucodeById(Map<String, Object> paramMap) throws DaoException {
		
		return (Map<String, Object>) this.mybatisInterfaceBaseDao.getObject("com.sayimo.maker.mall.goods.dao.GoodsListInterfaceDao.querySkucodeById",paramMap);
	}
	
	/**
	 * 
	* @Title: queryProviderByCode 
	* @Author: 田超
	* @Date:日期：2016年7月12日  时间：下午6:19:03
	* @Description: 根据code查询供应商id
	* @param providerCode
	* @return
	* @throws DaoException
	* @return Map<String,Object>
	* @Version 1.0.0
	 */
	@Override
	public Map<String, Object> queryProviderByCode(String providerCode) throws DaoException {
		
		return this.mybatisInterfaceBaseDao.queryMap("com.sayimo.maker.mall.goods.dao.GoodsListInterfaceDao.queryProviderByCode","id",providerCode);
	}
	/**
	* @Title: updateTimeComparison 
	* @Description: 时间戳对比
	* @param 
	* @throws DaoException
	* @return Map
	 */
	public Map updateTimeComparison() throws DaoException {
		
		return this.mybatisInterfaceBaseDao.queryMap("com.sayimo.maker.mall.goods.dao.GoodsListInterfaceDao.updateTimeComparison", "updateTime");
	}
	@Override
	public Map<String, Object> getActivityGoodsInfoByGoodsId(Integer goodsId,
			String goodsName, Integer activityId) throws DaoException {
		Map map=new HashMap();
		map.put("goodsId", goodsId);
		map.put("goodsName", goodsName);
		map.put("activityId", activityId);
		return (Map<String, Object>)this.mybatisInterfaceBaseDao.getObject("com.sayimo.maker.mall.goods.dao.GoodsListInterfaceDao.getActivityGoodsInfoByGoodsId", map);
	}
	@Override
	public Map<String, Object> getMoldbabyGoodsInfoByGoodsId(Integer goodsId,
			String goodsName, String identifier) throws DaoException {
		Map map=new HashMap();
		map.put("goodsId", goodsId);
		map.put("goodsName", goodsName);
		map.put("identifier", identifier);
		return (Map<String, Object>)this.mybatisInterfaceBaseDao.getObject("com.sayimo.maker.mall.goods.dao.GoodsListInterfaceDao.getMoldbabyGoodsInfoByGoodsId", map);
	}
	@Override
	public Map<String, Object> queryActivityGoodsInfoByGoodsId(Integer goodsId,
			String identifier) throws DaoException {
		Map map=new HashMap();
		map.put("goodsId", goodsId);
		map.put("identifier", identifier);
		return (Map<String, Object>)this.mybatisInterfaceBaseDao.getObject("com.sayimo.maker.mall.goods.dao.GoodsListInterfaceDao.queryActivityGoodsInfoByGoodsId", map);
	}
	
	/** 
	  * @package com.sayimo.school.mall.module.goods.dao
	  * @author chenpy
	  * @Title:  
	  * @Description: 
	  * @param 
	  * @throws 
	  * @return Map<String,Object>
	  * @date 2016年9月12日
	  */ 
	public Map<String, Object> getGoodsNormsValueInfo(Map paramMap) throws DaoException{
		return (Map<String, Object>) this.mybatisInterfaceBaseDao.getObject("com.sayimo.maker.mall.goods.dao.GoodsListInterfaceDao.getGoodsNormsValueInfo", paramMap);
	}
	
	/** 
	  * @package com.sayimo.school.mall.module.goods.dao
	  * @author chenpy
	  * @Title:  
	  * @Description: 统计商品被收藏次数和对应供应商下共有多少商品
	  * @param 
	  * @throws 
	  * @return Map
	  * @date 2016年10月27日
	  */ 
	public Map getStatisGoodsInfo(Map<String, Object> paramMap) throws DaoException{
		return (Map) this.mybatisInterfaceBaseDao.getObject("com.sayimo.maker.mall.goods.dao.GoodsListInterfaceDao.getStatisGoodsInfo", paramMap);
	}
	/**
	 * @Package com.sayimo.maker.mall.goods.dao.impl
	 * @Author TANXIN
	 * @MethodName:unionShopList
	 * @Description:联盟商家列表
	 * @return
	 * @throws DaoException
	 * @Date 2017年2月15日,上午9:44:29
	 */
	@Override
	public List unionShopList(Map<String, Object> paramMap) throws DaoException {
		return mybatisInterfaceBaseDao.queryObject("com.sayimo.maker.mall.goods.dao.GoodsListInterfaceDao.unionShopList",paramMap);
	}
	/**
	 * @Package com.sayimo.maker.mall.goods.dao.impl
	 * @Author TANXIN
	 * @MethodName:unionShopById
	 * @Description:联盟商家详情
	 * @param paramMap
	 * @return
	 * @throws DaoException
	 * @Date 2017年2月18日,下午2:09:50
	 */
	@Override
	public Map unionShopById(Map<String, Object> paramMap) throws DaoException {
		return (Map)mybatisInterfaceBaseDao.getObject("com.sayimo.maker.mall.goods.dao.GoodsListInterfaceDao.unionShopById",paramMap);
	}
	/**
	 * @Package com.sayimo.maker.mall.goods.dao.impl
	 * @Author 谭新
	 * @MethodName: getNormsValueIdByGoodsId
	 * @Description:通过商品Id 查询商品最小规格值id
	 * @Date 2017年4月10日,上午11:33:58
	 */
	@Override
	public Integer getNormsValueIdByGoodsId(Integer goodsId)
			throws DaoException {
		return mybatisInterfaceBaseDao.queryCount("com.sayimo.maker.mall.goods.dao.GoodsListInterfaceDao.getNormsValueIdByGoodsId",goodsId);
	}
}
